<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="renderer" content="webkit">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>科技创新人物奖申报书</title>
@include('common-css')
<style>
.input_box {
    width: 100%;
    height: 40px;
    margin-top: 15px;
    margin-bottom: 15px;
    display: flex;
    justify-content: flex-start;
    align-items: center;
}

.input_label {
    width: 120px;
    box-sizing: border-box;
}

.nav_sub_link.doc_download a {
    display: block;
    color: #666;
}
</style>
</head>
<body>
<div id="app">

</div>
</body>
</html>

<script id="appTemplate" type="x-template">
<a-locale-provider :locale="antdLocale">
    <div class="container">
        <header class="special">
            <div class="left_info">
                <!-- <img src="/images/icon1.png" alt=""> -->
                <h1>科技创新人物奖申报书</h1>
                <span>申报书所有项都需填写，如无内容填写"无"</span>
            </div>

            <div class="right_user">
                <div class="btn_box">
                    @if ($canEdit)
                        <a-button type="primary" @click="saveInput" :disabled="savingFormData">保存修改</a-button>
                    @endif
                </div>
            </div>

        </header>

        <main>


            <div class="common_container">

                <!-- 侧边栏 -->
                <nav class="common_nav">
                    <div class="nav_title">

                    </div>
                    <div class="nav_content">
                        <div class="nav_link">申报内容</div>
                        <div class="nav_sub_link" v-for="(tab,index) in navBar" :key="index"
                             :class="{'choose':index == currentIndex}" @click="changeBar(index,tab.anchor)">
                            @{{tab.name}}
                        </div>
                        <div class="nav_link">资料下载</div>
                        <div class="nav_sub_link doc_download">
                            <a href="/docs/承诺函-科技创新人物奖.doc" target="_blank">承诺函模板</a>
                        </div>
                        <div class="nav_sub_link doc_download">
                            <a href="/docs/2024年度中国公路建设行业协会科技创新人物奖推荐函（模板）.doc" target="_blank">推荐函模板</a>
                        </div>
                    </div>
                </nav>

                <!-- 内容外部容器区域 -->
                <div class="common_content">

                    <!-- 表单填写内容区域 -->
                    <div class="common_box">

                        <h4 class="common_title" id="one">基本信息</h4>

                        <div class="common_form">

                            <div class="common_form_input_3">
                                <div class="common_form_label">姓&emsp;&emsp;名</div>
                                <div class="common_form_box">
                                    <a-input v-model="formData.basic.name" placeholder="姓名"></a-input>
                                </div>
                            </div>


                            <div class="common_form_input_3">
                                <div class="common_form_label">性&emsp;&emsp;别</div>
                                <div class="common_form_box">

                                    <a-radio-group v-model="formData.basic.sex">
                                        <a-radio value="男">男</a-radio>
                                        <a-radio value="女">女</a-radio>
                                    </a-radio-group>
                                </div>
                            </div>


                            <div class="common_form_input_3">
                                <div class="common_form_label">本人照片
                                    <a-tooltip placement="top">
                                        <template slot="title">
                                            <span>一寸登记照</span>
                                        </template>
                                        <a-icon type="info-circle"/>
                                    </a-tooltip>
                                </div>
                                <div class="common_form_box">
                                    <a style="font-size: 14px; margin-right: 10px;" v-if="formData.basic.document_photo" :href="formData.basic.document_photo" target="_blank">查看</a>

                                    @if ($canEdit)
                                    <a-upload name="file" accept="image/*" :showUploadList="false" action="/api/common/upload" @change="handleDocumentPhotoUploadChange($event)">
                                        <a href="javascript:;">@{{ formData.basic.document_photo ? '替换' : '上传' }}</a>
                                    </a-upload>
                                    @endif

                                </div>
                            </div>

                        </div>

                        <div class="common_form">

                            <div class="common_form_input_3">
                                <div class="common_form_label">民&emsp;&emsp;族</div>
                                <div class="common_form_box">
                                    <a-input v-model="formData.basic.nation" placeholder="民族，如“汉族”"></a-input>
                                    </a-input>
                                </div>
                            </div>


                            <div class="common_form_input_3">
                                <div class="common_form_label">学&emsp;&emsp;历</div>
                                <div class="common_form_box">
                                    <a-input v-model="formData.basic.eduction" placeholder="学历"></a-input>
                                </div>
                            </div>


                            <div class="common_form_input_3">
                                <div class="common_form_label">学&emsp;&emsp;位</div>
                                <div class="common_form_box">
                                    <a-input v-model="formData.basic.degree" placeholder="学位"></a-input>
                                </div>
                            </div>

                        </div>

                        <div class="common_form">

                            <div class="common_form_input_3">
                                <div class="common_form_label">党&emsp;&emsp;派</div>
                                <div class="common_form_box">
                                    <a-input v-model="formData.basic.groups" placeholder="党派"></a-input>
                                </div>
                            </div>


                            <div class="common_form_input_3">
                                <div class="common_form_label">出生日期</div>
                                <div class="common_form_box">
                                    <a-input v-model="formData.basic.birth" placeholder="出生日期，如“1990-12-12”"></a-input>
                                </div>
                            </div>

                            <div class="common_form_input_3">
                                <div class="common_form_label">毕业时间</div>
                                <div class="common_form_box">
                                    <a-input v-model="formData.basic.graduate" placeholder="毕业时间，如“2003-6-9”"></a-input>
                                </div>
                            </div>


                        </div>

                        <div class="common_form">

                            <div class="common_form_input_3">
                                <div class="common_form_label">专业技术职务</div>
                                <div class="common_form_box">
                                    <a-input v-model="formData.basic.professional" placeholder="专业技术职务"></a-input>
                                </div>
                            </div>
                            <div class="common_form_input_3">
                                <div class="common_form_label">行政职务</div>
                                <div class="common_form_box">
                                    <a-input v-model="formData.basic.duty" placeholder="行政职务"></a-input>
                                </div>
                            </div>
                            <div class="common_form_input_3">
                                <div class="common_form_label"></div>
                                <div class="common_form_box">
                                </div>
                            </div>
                        </div>

                        <div class="common_form">

                            <div class="common_form_input_3">
                                <div class="common_form_label">E-mail</div>
                                <div class="common_form_box">
                                    <a-input v-model="formData.basic.mail" placeholder="常用邮箱地址"></a-input>
                                </div>
                            </div>
                            <div class="common_form_input_3">
                                <div class="common_form_label">手机号码</div>
                                <div class="common_form_box">
                                    <a-input v-model="formData.basic.phone" maxlength="11" placeholder="11位手机号码">
                                    </a-input>
                                </div>
                            </div>
                            <div class="common_form_input_3">
                                <div class="common_form_label"></div>
                                <div class="common_form_box">
                                </div>
                            </div>
                        </div>

                        <div class="common_form">
                            <div class="common_form_input_3">
                                <div class="common_form_label">工作单位全称</div>
                                <div class="common_form_box">
                                    <a-input v-model="formData.basic.company" placeholder="工作单位全称"></a-input>
                                </div>
                            </div>
                            <div class="common_form_input_3">
                                <div class="common_form_label">单位电话</div>
                                <div class="common_form_box">
                                    <a-input v-model="formData.basic.company_phone" placeholder="单位电话"></a-input>
                                </div>
                            </div>
                            <div class="common_form_input_3">
                                <div class="common_form_label"></div>
                                <div class="common_form_box">
                                </div>
                            </div>
                        </div>
                        <div class="common_form">
                            <div class="common_form_input_3">
                                <div class="common_form_label">单位地址</div>
                                <div class="common_form_box">
                                    <a-input v-model="formData.basic.company_address" placeholder="单位地址"></a-input>
                                </div>
                            </div>
                            <div class="common_form_input_3">
                                <div class="common_form_label">邮&emsp;&emsp;编</div>
                                <div class="common_form_box">
                                    <a-input v-model="formData.basic.company_email" placeholder="单位所在地邮编"></a-input>
                                </div>
                            </div>
                            <div class="common_form_input_3">
                                <div class="common_form_label"></div>
                                <div class="common_form_box">
                                </div>
                            </div>
                        </div>

                        <div class="common_form_area">

                            <div class="common_form_input_1">
                                <div class="common_form_label">社会职务</div>
                                <div class="common_form_box">
                                    <a-input type="textarea" resize="none" :rows="5" class="special_item"
                                             placeholder="社会职务"
                                             v-model="formData.basic.job">
                                    </a-input>
                                </div>
                            </div>

                        </div>

                        <div class="common_form_area">

                            <div class="common_form_input_1">
                                <div class="common_form_label">国内外学术组织任职情况</div>
                                <div class="common_form_box">
                                    <a-input type="textarea" resize="none" :rows="5" class="special_item"
                                             placeholder="简介国内外学术组织任职情况" v-model="formData.basic.situation">
                                    </a-input>
                                </div>
                            </div>

                        </div>

                        <div class="common_form_table">

                            <div class="common_form_input_1">
                                <div class="common_form_label">本人简历（从高校填起）</div>
                                <div class="common_form_box">

                                    <table class="form-data-table">
                                        <thead>
                                        <tr>
                                            <th>序号</th>
                                            <th>起止年月</th>
                                            <th>所在单位(学校)</th>
                                            <th>职务(专业)</th>
                                            <th>操作</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <tr v-for="(record, index) in formData.basic.resume" :key="index">
                                            <td>@{{ index + 1 }}</td>
                                            <td><a-input size="small" v-model="record.range" placeholder="格式: 2008/9-2012/9" /></td>
                                            <td><a-input size="small" v-model="record.address" placeholder="" /></td>
                                            <td><a-input size="small" v-model="record.experience" placeholder="" /></td>
                                            <td>
                                                    <span size="mini" type="text" class="common_dele"
                                                          @click="deleteRecord('resume', record)">删除</span>
                                            </td>
                                        </tr>
                                        </tbody>
                                    </table>

                                    <div class="add_new_tr" @click="addRecord('resume')">
                                        添加 +
                                    </div>

                                </div>
                            </div>

                        </div>
                        <!-- 分割线 -->
                        <div class="hr"></div>

                        <h4 class="common_title" id="two">所获科技奖励和荣誉称号情况</h4>
                        <div class="common_desc">(限市级及以上人民政府或全国性行业协会授予的奖励或荣誉)</div>
                        <div class="common_form_table">
                            <div class="common_form_input_1">
                                <div class="common_form_box">

                                    <table class="form-data-table">
                                        <thead>
                                        <tr>
                                            <th>序号</th>
                                            <th>奖励或荣誉名称</th>
                                            <th>授奖单位</th>
                                            <th>授奖日期</th>
                                            <th>获奖总人数</th>
                                            <th>本人排名</th>
                                            <th>操作</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <tr v-for="(record, index) in formData.award" :key="index">
                                            <td>@{{ index + 1 }}</td>
                                            <td><a-input size="small" v-model="record.award_name" placeholder="" /></td>
                                            <td><a-input size="small" v-model="record.company_of_issue" placeholder="" /></td>
                                            <td><a-input size="small" v-model="record.date" placeholder="格式: 2018/6/30" /></td>
                                            <td><a-input size="small" v-model="record.total" placeholder="" /></td>
                                            <td><a-input size="small" v-model="record.rank" placeholder="" /></td>
                                            <td>
                                                    <span size="mini" type="text" class="common_dele"
                                                          @click="deleteRecord('award', record)">删除</span>
                                            </td>
                                        </tr>
                                        </tbody>
                                    </table>

                                    <div class="add_new_tr" @click="addRecord('award')">
                                        添加 +
                                    </div>

                                </div>
                            </div>
                        </div>
                        <!-- 分割线 -->
                        <div class="hr"></div>

                        <h4 class="common_title" id="three">发表论文及专著情况</h4>
                        <div class="common_desc">(限填有代表性的论文和著作十篇（册）以内)</div>
                        <div class="common_form_table">
                            <div class="common_form_input_1">
                                <div class="common_form_box">

                                    <table class="form-data-table">
                                        <thead>
                                        <tr>
                                            <th>序号</th>
                                            <th>论文/著作<br />名称</th>
                                            <th>年份</th>
                                            <th>本人排名</th>
                                            <th>主要合作者</th>
                                            <th>发表刊物<br />或出版社名称</th>
                                            <th>本人作用<br />或主要贡献(限100字)</th>
                                            <th>操作</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <tr v-for="(record, index) in formData.paper" :key="index">
                                            <td>@{{ index + 1 }}</td>
                                            <td><a-input size="small" v-model="record.paper_name" placeholder="" /></td>
                                            <td><a-input size="small" v-model="record.date" placeholder="" /></td>
                                            <td><a-input size="small" v-model="record.rank" placeholder="" /></td>
                                            <td><a-input size="small" v-model="record.partner" placeholder="" /></td>
                                            <td><a-input size="small" v-model="record.publish" placeholder="" /></td>
                                            <td><a-input size="small" v-model="record.contribution" placeholder="" /></td>
                                            <td>
                                                    <span size="mini" type="text" class="common_dele"
                                                          @click="deleteRecord('paper', record)">删除</span>
                                            </td>
                                        </tr>
                                        </tbody>
                                    </table>

                                    <div class="add_new_tr" v-if="getDataArray('paper').length < 10"  @click="addRecord('paper')">
                                        添加 +
                                    </div>

                                </div>
                            </div>
                        </div>
                        <!-- 分割线 -->
                        <div class="hr"></div>

                        <h4 class="common_title" id="four">所获知识产权证书</h4>
                        <div class="common_desc">(限十项以内)</div>
                        <div class="common_form_table">
                            <div class="common_form_input_1">
                                <div class="common_form_box">

                                    <table class="form-data-table">
                                        <thead>
                                        <tr>
                                            <th>序号</th>
                                            <th>知识产权<br />类别</th>
                                            <th>授权项目<br />名称</th>
                                            <th>国(区)别</th>
                                            <th>授权号</th>
                                            <th>授权日期</th>
                                            <th>证书编号</th>
                                            <th>权利人</th>
                                            <th>发明人</th>
                                            <th>所对应<br />标志性成果</th>
                                            <th>证明材料<br />编号</th>
                                            <th>操作</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <tr v-for="(record, index) in formData.property" :key="index">
                                            <td>@{{ index + 1 }}</td>
                                            <td>
                                                <a-select style="width: 140px;" size="small" v-model="record.property_category">
                                                    <a-select-option v-for="ipType in ipTypes" :value="ipType" :key="ipType">@{{ ipType }}</a-select-option>
                                                </a-select>
                                            </td>
                                            <td><a-input size="small" v-model="record.item_name" placeholder="" /></td>
                                            <td><a-input size="small" v-model="record.country" placeholder="" /></td>
                                            <td><a-input size="small" v-model="record.authorization_num" placeholder="" /></td>
                                            <td><a-input size="small" v-model="record.authorization_date" placeholder="格式：2018/12/31" /></td>
                                            <td><a-input size="small" v-model="record.certificate_number" placeholder="" /></td>
                                            <td><a-input size="small" v-model="record.obligee" placeholder="" /></td>
                                            <td><a-input size="small" v-model="record.inventor" placeholder="" /></td>
                                            <td><a-input size="small" v-model="record.achievement" placeholder="" /></td>
                                            <td><a-input size="small" v-model="record.reference_number" placeholder="" /></td>
                                            <td>
                                                    <span size="mini" type="text" class="common_dele"
                                                          @click="deleteRecord('property', record)">删除</span>
                                            </td>
                                        </tr>
                                        </tbody>
                                    </table>

                                    <div class="add_new_tr" v-if="getDataArray('property').length < 10" @click="addRecord('property')">
                                        + 添加
                                    </div>

                                </div>
                            </div>
                        </div>
                        <!-- 分割线 -->
                        <div class="hr"></div>

                        <h4 class="common_title" id="five">承担科研项目情况</h4>
                        <div class="common_form_table">
                            <div class="common_form_input_1">
                                <div class="common_form_box">

                                    <table class="form-data-table">
                                        <thead>
                                        <tr>
                                            <th>序号</th>
                                            <th>项目名称</th>
                                            <th>研发经费(万)</th>
                                            <th>项目来源</th>
                                            <th>项目编号</th>
                                            <th>研发起止时间</th>
                                            <th>状态</th>
                                            <th>负责人</th>
                                            <th>本人在项目<br />成果中排序</th>
                                            <th>证明材料<br />编号</th>
                                            <th>操作</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <tr v-for="(record, index) in formData.scientific" :key="index">
                                            <td>@{{ index + 1 }}</td>
                                            <td><a-input size="small" v-model="record.project_name" placeholder="" /></td>
                                            <td><a-input size="small" v-model="record.expenditure" placeholder="" /></td>
                                            <td><a-input size="small" v-model="record.project_origin" placeholder="" /></td>
                                            <td><a-input size="small" v-model="record.project_number" placeholder="" /></td>
                                            <td><a-input size="small" v-model="record.development_date" placeholder="" /></td>
                                            <td>
                                                <a-select style="width: 80px;" size="small" v-model="record.status">
                                                    <a-select-option v-for="statusType in ['在研', '已验收']" :value="statusType" :key="statusType">@{{ statusType }}</a-select-option>
                                                </a-select>
                                            </td>
                                            <td><a-input size="small" v-model="record.principal" placeholder="" /></td>
                                            <td><a-input size="small" v-model="record.sort" placeholder="" /></td>
                                            <td><a-input size="small" v-model="record.reference_number" placeholder="" /></td>
                                            <td>
                                                    <span size="mini" type="text" class="common_dele"
                                                          @click="deleteRecord('scientific', record)">删除</span>
                                            </td>
                                        </tr>
                                        </tbody>
                                    </table>

                                    <div class="add_new_tr" @click="addRecord('scientific')">
                                        + 添加
                                    </div>

                                </div>
                            </div>
                        </div>
                        <!-- 分割线 -->
                        <div class="hr"></div>

                        <h4 class="common_title" id="six">参与重大工程科技项目情况</h4>
                        <div class="common_form_table">
                            <div class="common_form_input_1">
                                <div class="common_form_box">


                                    <table class="form-data-table">
                                        <thead>
                                        <tr>
                                            <th>序号</th>
                                            <th>项目名称</th>
                                            <th>项目委托单位</th>
                                            <th>本人参与情况</th>
                                            <th>经济效益(万元)</th>
                                            <th>操作</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <tr v-for="(record, index) in formData.engineering" :key="index">
                                            <td>@{{ index + 1 }}</td>
                                            <td><a-input size="small" v-model="record.project_name" placeholder="" /></td>
                                            <td><a-input size="small" v-model="record.issue_company" placeholder="" /></td>
                                            <td><a-input size="small" v-model="record.aboutme" placeholder="" /></td>
                                            <td><a-input size="small" v-model="record.economic" placeholder="" /></td>
                                            <td>
                                                    <span size="mini" type="text" class="common_dele"
                                                          @click="deleteRecord('engineering', record)">删除</span>
                                            </td>
                                        </tr>
                                        </tbody>
                                    </table>

                                    <div class="add_new_tr" @click="addRecord('engineering')">
                                        + 添加
                                    </div>

                                </div>
                            </div>
                        </div>
                        <!-- 分割线 -->
                        <div class="hr"></div>

                        <h4 class="common_title" id="seven">科技成果转化及推广情况</h4>
                        <div class="common_form_area">

                            <div class="common_form_input_1">
                                <div class="common_form_box">
                                    <a-input type="textarea" resize="none" :rows="5" class="special_item"
                                             placeholder="简介科技成果转化及推广情况" v-model="formData.situation">
                                    </a-input>
                                </div>
                            </div>

                        </div>
                        <!-- 分割线 -->
                        <div class="hr"></div>

                        <h4 class="common_title" id="eight">附件</h4>
                        <div class="common_desc">文件大小限制：100M。允许上传的文件格式：压缩包(zip/rar)，PDF文档，Office文档(Word/Excel/PPT)，图片(jpg/png)。</div>

                        <table class="form-attachments-table">
                            <tr v-for="(attachmentItem,index) in attachmentItems" :key="index">
                                <td>@{{ index + 1 }}.</td>
                                <td>@{{ attachmentItem.name }}</td>
                                <td class="status">
                                    <span v-if="formData.attachments[attachmentItem.key]">已上传</span>
                                    <span style="color: orange;" v-else>未上传</span>
                                </td>
                                <td class="operations">
                                    <span v-if="formData.attachments[attachmentItem.key]">
                                        <a :href="formData.attachments[attachmentItem.key]" target="_blank">查看</a>
                                    </span>

                                    @if ($canEdit)
                                    <a-upload v-if="attachmentItem.accept_upload_type == 'pdf'" name="file" accept=".pdf" :showUploadList="false" action="/api/common/upload" :data="{accept_file_type: 'pdf'}" :beforeUpload="handleAttachmentBeforeUpload" @change="handleAttachmentUploadChange($event, attachmentItem)">
                                        <a href="javascript:;">@{{ formData.attachments[attachmentItem.key] ? '替换' : '上传' }}</a>
                                    </a-upload>
                                    <a-upload v-else name="file" accept=".zip,.rar,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.pdf,.jpg,.jpeg,.gif,.png,.tif,.bmp" :showUploadList="false" action="/api/common/upload" :beforeUpload="handleAttachmentBeforeUpload" @change="handleAttachmentUploadChange($event, attachmentItem)">
                                        <a href="javascript:;">@{{ formData.attachments[attachmentItem.key] ? '替换' : '上传' }}</a>
                                    </a-upload>
                                    @endif

                                </td>
                            </tr>
                        </table>

                    </div>

                </div>

            </div>

        </main>
    </div>

</a-locale-provider>
</script>

@include('common-js')

<script>
var applicationId = {{ Request::get('id') }};
var formData = {!! json_encode($formData, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT) !!};

Vue.prototype.$axios = axios
var app = new Vue({
    el: '#app',
    template: '#appTemplate',
    data: {
        formData: {
            type: 'talent', //科技人物奖
            // 基本信息
            basic: {
                name: '', //姓名
                sex: '男', //性别 0 女， 1 男
                document_photo: '', //证件照
                nation: '', //民族
                eduction: '', //学历
                groups: '', //党派
                degree: '', //学位
                birth: '', //出生日期
                duty: '', //行政职务
                professional: '', //专业技术职务
                phone: '', //手机号码
                graduate: '', //毕业时间
                company_phone: '', //单位电话
                mail: '', //e-mail
                company: '', //工作单温名称
                company_address: '', //工作单位地址
                company_email: '', //工作单位邮编
                job: '', //社会职务
                situation: '', //国内外学术组织任职情况
                resume: [] //本人简历

            },
            award: [], //所获科技奖励和荣誉称号情况
            paper: [], //发表论文及专著情况
            property: [], //所获知识产权证书
            scientific: [], //承担科研项目情况
            engineering: [], //参与重大工程科技项目情况
            situation: '', //科技成果转化及推广情况,
            attachments: {
                commitment_letter:null,
                tech_awards: null,
                publications: null,
                ip_certs: null,
                project_files: null,
                benefit_certs: null,
                recommend_letter: null,
                others: null
            }
        },
        attachmentItems: [
            {
                name: '承诺函 PDF 扫描件（模板见左侧资料下载）',
                key: 'commitment_letter',
                accept_upload_type: 'pdf',
            },
            {
                name: '推荐函 PDF 扫描件 (需加盖推荐单位公章)',
                accept_upload_type: 'pdf',
                key: 'recommend_letter'
            },
            {
                accept_upload_type: 'all',
                name: '科技奖励和荣誉称号证书或文件',
                key: 'tech_awards'
            },
            {
                name: '代表性论文、专著(不超过10篇)',
                accept_upload_type: 'all',
                key: 'publications'
            },
            {
                name: '所获知识产权证书',
                accept_upload_type: 'all',
                key: 'ip_certs'
            },
            {
                name: '承担科研项目立项或验收文件',
                accept_upload_type: 'all',
                key: 'project_files'
            },
            {
                name: '效益证明',
                accept_upload_type: 'all',
                key: 'benefit_certs'
            },
            {
                name: '其他证明或补充材料',
                accept_upload_type: 'all',
                key: 'others'
            }
        ],
        ipTypes: ['发明专利', '外观', '实用新型', '标准', '软件著作权', '集成电路布图设计', '其它'],
        arrayElementDefs: {
            resume: { //本人简历填写项
                range: '', //起止年月
                address: '', //所在单位
                experience: '' //职务
            },
            award: { //获奖及荣誉填写项
                date: '', //授奖日期
                total: '', //总人数
                rank: '', //个人排名
                company_of_issue: '', //授奖单位
                award_name: '' //奖名
            },
            paper: { //发表论文及专著情况填写
                paper_name: '', //论文名
                date: '', //年份
                partner: '', //合作者
                rank: '', //本人排名
                publish: '', //发表出版社
                contribution: '' //个人贡献
            },
            property: { //知识产权
                property_category: '', //类别
                item_name: '', //名称
                country: '', //国家
                authorization_num: '', //授权号
                authorization_date: '', //授权日期
                certificate_number: '', //证书号码
                obligee: '', //权利人
                inventor: '', //发明人
                achievement: '', //成果
                reference_number: '' //证书材料编号
            },
            scientific: { //承担科研项目情况
                project_name: '', //项目名称
                development_date: '', //研发起止时间
                expenditure: '', //研发经费
                project_origin: '', //项目来源
                project_number: '', //项目编号
                status: '在研',
                principal: '', //负责人
                sort: '', //个人排序
                reference_number: '', //证明材料编号
            },
            engineering: { //重大工程及项目情况
                project_name: '', //项目名称
                issue_company: '', //委托单位
                aboutme: '', //个人参与情况
                economic: '' //经济效益
            }
        },
        navBar: [{
            name: '基本信息',
            anchor: 'one'
        },
            {
                name: '所获科技奖励和荣誉称号情况',
                anchor: 'two'
            },
            {
                name: '发表论文和专著情况',
                anchor: 'three'
            },
            {
                name: '所获知识产权证书',
                anchor: 'four'
            },
            {
                name: '承担科研项目情况',
                anchor: 'five'
            },
            {
                name: '参与重大工程技术项目情况',
                anchor: 'six'
            },
            {
                name: '科技成果转化及推广情况',
                anchor: 'seven'
            },
            {
                name: '附件',
                anchor: 'eight'
            }
        ],
        currentIndex: 0,
        applicationId: applicationId,
        savingFormData: false,
        antdLocale: antd.locales.zh_CN
    },
    mounted() {
        copyFieldValueFromObject(this.$data.formData, formData, this.arrayElementDefs)
    },
    methods: {
        validateFormData() {
            let { basic, award, paper, property, scientific, engineering, situation, attachments} = this.formData

            if (!basic.name) {
                return "请填写姓名"
            } else if (!basic.document_photo) {
                return "请上传证件照"
            } else if (!basic.nation) {
                return "请填写民族"
            } else if (!basic.eduction) {
                return "请填写最高学历"
            } else if (!basic.groups) {
                return "请填写党派"
            } else if (!basic.degree) {
                return "请填写学位"
            } else if (!basic.birth) {
                return "请填写出生日期"
            } else if (!basic.duty) {
                return "请填写行政职务"
            } else if (!basic.professional) {
                return "请填写专业技术职务"
            } else if (!basic.phone) {
                return "请填写手机号码"
            } else if (!basic.graduate) {
                return "请填写毕业时间"
            } else if (!basic.company_phone) {
                return "请填写单位电话"
            } else if (!basic.mail) {
                return "请填写电子邮箱"
            } else if (!basic.company) {
                return "请填写工作单位名称"
            } else if (!basic.company_address) {
                return "请填写工作单位地址"
            } else if (!basic.company_email) {
                return "请填写邮编"
            } else if (!basic.job) {
                return "请填写社会职务"
            } else if (!basic.situation) {
                return "请填写国内外学术组织任职情况"
            } else if (basic.resume.length == 0) {
                return "请添加简历"
            }

            if (award.length == 0) {
                return "请添加所获科技奖励和荣誉称号"
            }
            if (paper.length == 0) {
                return "请添加发表论文及专著"
            }
            if (property.length == 0) {
                return "请添加所获知识产权证书"
            }
            if (scientific.length == 0) {
                return "请添加承担科研项目"
            }
            if (engineering.length == 0) {
                return "请添加参与重大工程科技项目"
            }
            if (!situation) {
                return "请填写科技成果转化及推广情况"
            }
            if (!attachments.tech_awards) {
                return "请上传附件科技奖励和荣誉称号证书或文件"
            } else if (!attachments.publications) {
                return "请上传代表性论文、专著"
            } else if (!attachments.ip_certs) {
                return "请上传所获知识产权证书"
            } else if (!attachments.project_files) {
                return "请上传承担科研项目立项或验收文件"
            } else if (!attachments.benefit_certs) {
                return "请上传效益证明"
            }
            return false

        },
        // 保存修改表单
        saveInput(options) {
            if (typeof options === 'undefined') {
                options = {}
            }
            console.log('data', this.formData)

            // var error = this.validateFormData()
            // if (error)
            // {
            //     antd.message.warn(error, 3)
            //     return
            // }

            this.savingFormData = true
            if (!options.silent) {
                antd.message.loading('正在处理，请稍候', 0)
            }
            axios.post('/api/award/save-form-data', {
                id: this.applicationId,
                form_data: this.formData
            }).then(res => {
                if (!options.silent) {
                    antd.message.destroy()
                }
                console.log(res)
                var data = res.data
                if (data.ok) {
                    if (!options.silent) {
                        antd.message.success('申报书修改已保存')
                    }
                } else {
                    antd.message.warn(data.message, 3)
                }
                this.savingFormData = false
            })
        },
        handleDocumentPhotoUploadChange(event) {
            console.log('handleDocumentPhotoUploadChange', event)
            if (event.file.status == 'done') {
                if (event.file.response.ok) {
                    antd.message.success(event.file.name + '照片上传成功')
                    this.formData.basic.document_photo = event.file.response.url
                    this.saveInput({silent: true})
                } else {
                    antd.message.warn(event.file.name + '上传失败')
                }
            }
        },
        handleAttachmentBeforeUpload(file) {
            console.log('handleAttachmentBeforeUpload', file)
            var filename = file.name.toLowerCase()
            var pos = filename.lastIndexOf('.')
            if (pos === -1) {
                antd.message.warn('不允许上传该文件格式')
                return false
            }
            var extension = filename.substring(pos + 1)
            if (['zip', 'rar', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'pdf', 'jpg', 'jpeg', 'gif', 'png', 'tif', 'bmp'].includes(extension)) {
                // antd.message.loading('正在上传，请稍候', 0)
                return true
            } else {
                antd.message.warn('不允许上传该文件格式')
                return false
            }
        },
        handleAttachmentUploadChange(event, attachmentItem) {
            console.log('handleAttachmentUploadChange', event, attachmentItem)
            if (event.file.status == 'done') {
                antd.message.destroy()
                antd.notification.close('uploading')
                if (event.file.response.ok) {
                    antd.message.success(event.file.name + '上传成功')
                    this.formData.attachments[attachmentItem.key] = event.file.response.url
                    this.saveInput({silent: true})
                } else {
                    antd.message.warn(event.file.name + '上传失败')
                }
            } else if (event.file.status == 'uploading') {
                antd.notification.open({
                    key: 'uploading',
                    message: '正在上传',
                    description: `进度：${parseInt(event.file.percent)}%`,
                    duration: null,
                })
            } else if (event.file.status == 'error') {
                antd.notification.close('uploading')
                antd.message.error('文件大小超过限制，上传失败')
            }
        },
        addRecord(arrayId) {
            var array = this.getDataArray(arrayId)
            var record = {...this.arrayElementDefs[arrayId]}
            array.push(record)
        },
        deleteRecord(arrayId, record) {
            var array = this.getDataArray(arrayId)
            var pos = array.indexOf(record)
            if (pos > -1) {
                array.splice(pos, 1)
            }
        },
        getDataArray(arrayId) {
            var array
            switch (arrayId) {
                case 'resume':
                    array = this.formData.basic.resume
                    break
                case 'award':
                    array = this.formData.award
                    break
                case 'paper':
                    array = this.formData.paper
                    break
                case 'property':
                    array = this.formData.property
                    break
                case 'scientific':
                    array = this.formData.scientific
                    break
                case 'engineering':
                    array = this.formData.engineering
                    break
            }
            return array
        },
        changeBar(index, anchorName) {
            this.currentIndex = index
            document.querySelector(`#${anchorName}`).scrollIntoView()
        },
    }
})
</script>